<template>
  <div class="about">
    <div class="form-group">
      <label>用户名</label>
      <input type="text" v-model="userName" class="form-control">
    </div>
    <div class="form-group">
      <label>密码</label>
      <input type="text" class="form-control" v-model="pwd">
    </div>
    <div class="form-group">
      <button class="btn btn-success btn-block" @click="loginSub">登陆</button>
    </div>
  </div>
</template>

<script>
import { login } from '../services/member';

export default {
  name: 'About',
  data() {
    return {
      userName: '',
      pwd: '',
    };
  },
  methods: {
    loginSub() {
      if (this.userName === '') {
        alert('用户名不能为空');
        return;
      }
      if (this.pwd === '') {
        alert('密码不能为空');
        return;
      }
      login({
        userName: this.userName,
        pwd: this.pwd,
      })
      .then((res) => {
        alert(res.data.msg);
      });
    },
  },
};
</script>

<style>

</style>

